using System;
using System.Collections.Generic;
using System.Text;
using Refly.CodeDom;
using Refly.CodeDom.Statements;
using Refly.CodeDom.Expressions;

namespace Doubler.Templates.Recorder.RecorderActions
{
    public class ThrowException : RecorderActionBase
    {
        protected override void doAct(Refly.CodeDom.IClassDeclaration recorder
            , Refly.CodeDom.MethodDeclaration recorderMethod
            , Refly.CodeDom.Expressions.NativePropertyReferenceExpression recordingProperty
            , Reflector.CodeModel.ITypeReference subject
            , Reflector.CodeModel.IMethodDeclaration methodInformation)
        {
            Expression ExceptionToThrow = recordingProperty.Prop(RecorderGenerator.RecordingExceptionToThrow);
            ConditionStatement IfThrow = Stm.IfNotNull(ExceptionToThrow, Stm.Throw(ExceptionToThrow));
            recorderMethod.Body.Add(IfThrow);
        }
    }
}
